#!/usr/bin/env bash


while getopts ":p:n:w:" opt
do
    case $opt in
        p)
        export p=$OPTARG
        ;;
        n)
        export n=$OPTARG
        ;;
        w)
        export w=$OPTARG
        ;;
        ?)
        echo "未知参数"
        exit 1;;
    esac
done
port=${p-8080}
name=${n-laravel}
workspace=${w-"./"}
realdir(){
export realdir=`cd  $1; pwd`
}
realdir ${workspace}
echo ${realdir}
export d_pwd=`pwd`
docker pull  ccq18/fpm-nginx:v2
docker rm -f ${name}
docker run --name ${name}  -p ${port}:80 \
  -v ${d_pwd}/docker:/ext  \
  -v ${realdir}:/www \
  -v ${realdir}/storage/logs:/var/log \
  -d ccq18/fpm-nginx:v2 \
   "/ext/entrypoint.sh"

